User blog:FMF/Creating a database
__TOC__ Item Pages as Databeses Every page can contain data that can be called from other pages *I created a page called Template:Test/Sorcerer *The page contains the following data: }}} |name = Sorcerer |image = Sorcerer.jpg |quality = Rare |b = 1 |t = 2 |i = 3 |type = Body |special = 8% to harass when defending |text = This is a test |seals = pp++- }} }} *The switch function enclosed in onlyinclude tags (colored in blue) contains all the data, it's the database (the onlyinclude tags tell the wiki to only take the info enclosed by them when transcluding, thus you can add more info outside and it won't damage the functionality. * }} is calling the template that creates the card from the info within the page (a modified version of Template:Item Card), this can be done on other pages by simply changing into the name of the page that you want create a card for, in our case → ---- ---- *I created a modified version of Template:Production Item that takes the info from the page entered under | Result = ? *The following text is us calling the template: Our Code= |-| Optimal Code (if each page was a DB) = 13 |-| What we do today for the same result= 22 Using Template:test/production ---- using Template:Production Item ---- Summary (as I see it) Pros: * Reduces redundancy * Easily withdraw data from items * Changes in stats/info are globalie. change just once to edit all pages that use the data Cons * Takes time to get used to it * Must force refresh first time a page is createdThat's because the page uses a cached version of itself, to force refresh you just add ?action=purge to the address * Can cause to reach node limiton pages with hundreds of transclusions - there are several ways to avoid this but I can confirm that this method works on another wiki with a page that transcludes 208 items, displaying 10 parameters from each albeit it can be a bit laggy to save a page like that that much data once you edit it - that's more than 2080 quaries in one page!, no lag on pages with a bit less than that amount The two methods are: #use slightly different syntax to create a page that sends all the parameters to a template of your choosing, that way it converts checking a switch function several times with a way to call templates with all the parameters. this will avoid reaching the node count even with thousands of calls #using the tab view tags - this renders the pages instead of transcluding them, in this way you can display several heavy pages without reaching the limit * May prevent the wiki from noticing there are images for the thumbnails in category pages Another Thing - Autocategorization Although it's not entirely relevant to this blog page, I'd also suggest using autocategorization of pages by the templates they use, this is in order to both make sure a page is categorized correctly, and let you change categories globally (see note #1 below). It is possible to autocategorize into many categories example: Sorcerer can be autocategorized based on the data you enter to: Companions, Peerless Companions, Intrigue Companions, Trade Companions and more (depending on the data you enter). Sorry for the length and thanks for reading ---- Notes Category:Blog posts